//
//  InputView.m
//  Test
//
//  Created by fh on 2021/11/18.
//  Copyright © 2021 cashchina. All rights reserved.
//

#import "InputView.h"

@interface InputView ()
@property (nonatomic, strong) UILabel *nameLabel;

@end

@implementation InputView

- (instancetype)initWithKey:(NSString *)key value:(NSString *)value {
    if (self = [super init]) {
        [self setupView];
        self.nameLabel.text = key;
        self.textField.text = value;
    }
    return self;
}

- (void)setupView {
    [self addSubview:self.nameLabel];
    [self addSubview:self.textField];
    __weak typeof(self) weakSelf = self;
    [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(0));
        make.left.equalTo(@(0));
        make.bottom.equalTo(@(0));
    }];
    [self.textField mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(0));
        make.right.equalTo(@(0));
        make.bottom.equalTo(@(0));
        make.height.equalTo(@(44));
        make.left.equalTo(weakSelf.nameLabel.mas_right).offset(10);
    }];
    
}

#pragma mark - Setter and getter
- (UILabel *)nameLabel {
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.textColor = [UIColor blackColor];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        _nameLabel.text = @"default";
    }
    return _nameLabel;
}
- (UITextField *)textField {
    if (!_textField) {
        _textField = [[UITextField alloc] init];
        _textField.font = [UIFont systemFontOfSize:14];
        _textField.borderStyle = UITextBorderStyleLine;
    }
    return _textField;
}
@end
